﻿@using BXJG.Common.Events
@using BXJG.Utils.Application.Share.Session
@using BXJG.Utils.RCL

@inject NavigationManager nav

<Space @attributes=AdditionalAttributes Size="@("large")">
    @if (loginInformations != default)
    {
        <SpaceItem>
            <Dropdown>
                <Overlay>
                    <Menu>
                        <MenuItem Icon="user" @key="1" OnClick=@(()=>UserCenterClick("/uc-jbxx")) Style="padding-left:0.5rem;">基本信息</MenuItem>
                        <MenuItem Icon="idcard" @key="2" OnClick=@(()=>UserCenterClick("/uc-zhgl")) Style="padding-left:0.5rem;">账户管理</MenuItem>
                        <MenuItem Icon="setting" @key="3" OnClick=@(()=>UserCenterClick("/uc-gxsz")) Style="padding-left:0.5rem;">个性设置</MenuItem>
                        <MenuItem Icon="history" @key="4" OnClick=@(()=>UserCenterClick("/uc-wdrz")) Style="padding-left:0.5rem;">我的日志</MenuItem>
                        <MenuItem Icon="logout" @key="5" OnClick="LogoutClick" Style="padding-left:0.5rem;">注销</MenuItem>
                    </Menu>
                </Overlay>
                <ChildContent>
                    @if (loginInformations.User != default)
                    {
                        <Avatar Size="small" Style="background-color:aqua; color:#333;">
                            @loginInformations.User.Surname
                        </Avatar>
                        <span style=" color:#eee;">
                            @(loginInformations.User.Surname + loginInformations.User.Name)
                        </span>
                    }
                </ChildContent>
            </Dropdown>
        </SpaceItem>
    }

    <SpaceItem>
        <Tooltip Placement="@Placement.Bottom" Title="在线人数">
            <Badge Size="small" Count="5" OverflowCount="99">
                <Icon Type="user-switch" Theme="outline" Style="color:#aaa;" />
            </Badge>
        </Tooltip>

    </SpaceItem>
</Space>
@code {
    [Parameter(CaptureUnmatchedValues = true)]
    public IDictionary<string, object>? AdditionalAttributes { get; set; }

    [Inject]
    public Zhongjie Zhongjie { get; set; }

    bool MainMenuCollapsed;
    [Inject]
    public ILogger<StaticLayout> Logger { get; set; }

    [Inject]
    public Task<GetCurrentLoginInformationsOutput> AppContainer { get; set; }
    //bool isAuthed => loginInformations.User != default && loginInformations.User.Id > 0;
    GetCurrentLoginInformationsOutput loginInformations;// => AppContainer.CurrentLoginInformations;// new GetCurrentLoginInformationsOutput();


    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        loginInformations = await AppContainer;

    }
    void UserCenterClick(string url)
    {
        nav.NavigateTo(url);
    }

    void LogoutClick(MouseEventArgs e)
    {
        nav.NavigateTo("/account/logout", true);
    }
}
